﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace Common
{
    public class ReaderDll
    {
        /// <summary>
        /// 初始化动态库
        /// </summary>
        /// <param name="m_hWnd">窗口句柄，用于发送异步消息</param>
        /// <param name="msg">消息起始值</param>
        /// <param name="strParams">初始化时，所需要的附加信息</param>
        /// <returns>成功返回0，否则返回其他</returns>
        [DllImport("ReaderCard.dll")]
        public static extern int InitPersoDLL(IntPtr hWnd, int msg, string strParams);


        /// <summary>
        /// 卡片个人化
        /// </summary>
        /// <param name="nIndex">个人化工位索引(第几个个人化工位)</param>
        /// <param name="nCardID">卡片ID</param>
        /// <param name="cPersoData">个性化数据(EmpParams格式)</param>
        /// <returns></returns>
        [DllImport("ReaderCard.dll")]
        public static extern int CardPerso(int nIndex, int nCardID, string cPersoData);

        /// <summary>
        /// 获取个人化信息   获取个人化工位完成后的信息(比如个人化时间、传给其他工位的消息)
        /// </summary>
        /// <param name="nIndex">个人化工位索引(第几个个人化工位)</param>
        /// <param name="cOutarray">个人化工位信息</param>
        /// <param name="nOutLen">信息长度</param>
        /// <returns>成功返回0，否则返回其他错误代码</returns>
        [DllImport("ReaderCard.dll")]
        public static extern int GetPersoInfo(int nIndex, byte[] cOutarray, ref int nOutLen);

        /// <summary>
        /// 注销个人化动态库
        /// </summary>
        /// <returns>成功返回0，否则返回其他错误代码</returns>
        [DllImport("ReaderCard.dll")]
        public static extern int UnInitPersoDLL(); 

    }
}
